package com.ebt.m.proposal_v2.widget.dialog;

import android.view.Gravity;
import android.widget.ScrollView;
import android.widget.TextView;

import com.ebt.m.R;
import com.ebt.m.proposal_v2.helper.ThemeHelper;

/**
 * 提示窗口
 *
 * @author archer.qi
 *         Created on 2017/5/18.
 */
public class EBTTipDialog extends EBTDialogBase {

    private TextView messageView;
    private String msg;
    private ScrollView scrollView;
    @Override
    public void init() {
        setTitle("提示");
        scrollView = generateScrollView();
        messageView = generateTextView();
        if (msg != null) {
            messageView.setText(msg);
        }
        scrollView.addView(messageView);
        addDialogBody(scrollView);
        setSingleButton(true);
        setPositiveButton("确定", v -> dismiss());
        setCancelable(false);
    }

    private TextView generateTextView() {
        TextView view = new TextView(getActivity());
        view.setPadding(32, 60, 32, 60);
        view.setTextColor(ThemeHelper.getColor(getActivity(), R.color.PrimaryContentColor));
        view.setTextSize(16);
        view.setGravity(Gravity.LEFT);
        return view;
    }

    private ScrollView generateScrollView() {
        ScrollView view = new ScrollView(getActivity());
        return view;
    }

    public EBTTipDialog setMessage(String s) {
        msg = s;
        return this;
    }
}
